﻿<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->

<head>
<meta charset="utf-8">
<title>有色废旧</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="" name="description">
<meta content="" name="author">
<script>BASE_URL ='${request.getContextPath()}'</script>
<link href="${request.getContextPath()}/Public/assets/admin/css/css.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/simple-line-icons/simple-line-icons.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/css/bootstrap.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/uniform/css/uniform.default.css"
	rel="stylesheet" type="text/css">

<link
	href="${request.getContextPath()}/Public/assets/global/css/components-rounded.css"
	id="style_components" rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/css/plugins.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/layout.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/themes/default.css"
	rel="stylesheet" type="text/css" id="style_color">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/custom.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css"
	rel="stylesheet" type="text/css">

<link
	href="${request.getContextPath()}/Public/assets/admin/css/common.css"
	rel="stylesheet" type="text/css">

<link rel="shortcut icon"
	href="${request.getContextPath()}/Public/favicon.ico">
<link href="${request.getContextPath()}/Public/css/client.css"
	rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/assets/global/css/kkpager.css" rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/css/customerDetail.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="${request.getContextPath()}/Public/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
body {
	margin: 0;
	padding: 0;
}
/*div_Import */
#div_Import {
	position: fixed;
	z-index: 999;
	width: 600px;
	height: 400px;
	border: 1px solid #ccc;
	background: #efefef;
	display: none;
	overflow: auto;
	border-radius:10px;
}

#div_Import .tit {
	background: #ddd;
	display: block;
	height: 15px;
	width:600px;
	margin:0 auto;
}

#div_Import .tit_NC {
	background: #26a69a;
	display: block;
	height: 24px;
}

#div_Import .tit i {
	float: right;
	line-height: 15px;
	padding: 0 8px;
	cursor: pointer;
}
</style>
</head>

<body class="page-header-top-fixed">
<!--头部信息结束 -->
<div class="page-header">
	<!--头部开始-->
	<#include "/include/top.html" />
	<!-- 头部信息结束 -->


	<!-- 头部菜单开始 -->
	<#include "/include/top_menu.html" />
	<!-- 头部菜单结束 -->
</div>
	<!-- END HEADER -->


	<!-- BEGIN PAGE CONTAINER -->
	<div class="page-container">
		<!-- 内容开始 -->
		<div class="page-content">
			<div class="container-fluid">
				<!-- 当前位置提示开始 -->
				<ul class="page-breadcrumb breadcrumb">
					<li>
						<a href="#">首页</a><i class="fa fa-circle"></i>
					</li>
					<li class="active">
						 客户管理<i class="fa fa-circle"></i>
					</li>
					<li class="active">
						 客户
					</li>
				</ul>
				<!-- 当前位置提示结束 -->
				<div class="row margin-top-10">
					<div class="col-md-12">
						<div class="portlet light bordered">
							<div class="portlet-body" style="height: 13px;padding-top: 2px">
								<div style="float: left;">
									视图：
									<a href="${request.getContextPath()}/customer/customerList.do?type=1" id="allClient" <#if type ?? && type == 1>class="btn green"<#else>class="btn btn-default"</#if>>全部</a>
									<a href="${request.getContextPath()}/customer/customerList.do?type=2" <#if type ?? && type == 2>class="btn green"<#else>class="btn btn-default"</#if>>我的客户</a>
									<a href="${request.getContextPath()}/customer/customerList.do?type=3" <#if type ?? && type == 3>class="btn green"<#else>class="btn btn-default"</#if>>部门客户</a>
								</div>
								<div style="float: right;">
									<i class="fa fa-clock-o"></i> <a
										href="${request.getContextPath()}/customer/customerList.do?dayType=1">今日新建</a>
									| <a href="${request.getContextPath()}/customer/customerList.do?dayType=2"
										id="createWeek">最近7天</a> | <a
										href="${request.getContextPath()}/customer/customerList.do?dayType=3"
										id="createMonth">本月新建</a> | <a
										href="${request.getContextPath()}/customer/customerList.do?dayType=4"
										id="recentModify">最近修改</a> &nbsp; &nbsp;<i
										class="fa fa-trash-o"></i> <a
										href="${request.getContextPath()}/customer/customerList.do?dayType=5&saleType=${saleType!''}">回收站</a>
								</div>
							</div>
						</div>
					</div>
				
					<div class="col-md-12">
						<div class="portlet light bordered"
							style="margin-bottom:-1px; padding:0;" id="hide_div_1">
							<a href="${request.getContextPath()}/customer/customerList.do?saleType=1"
								id="purchase" 
								<#if saleType?? &&  saleType ='1'>class="headerLine chosen"<#else>class="headerLine"</#if>>我的采购企业</a> <a
								href="${request.getContextPath()}/customer/customerList.do?saleType=2"
								id="supply" 
								<#if saleType?? && saleType ='2'>class="headerLine chosen"<#else>class="headerLine"</#if>>我的供应商</a>
								
								
						</div>
							<form action="${request.getContextPath()}/customer/customerList.do"
								method="post">
								<input type="hidden" id="saleType" name="saleType" value="${saleType!''}">
						<div class="portlet light bordered"
							style="margin-bottom:-1px; padding:20;" id="hide_div_3">
							
							<table style="padding-bottom: 10px" >
							<tr style="margin:20px;display:block;">
							<td>	<div style="width:150px;float:left;padding-left: 20px">
												<select name="nameType" id="nameType" class="form-control" onchange="selectColumn()">
													<option value="" <#if nameType?? &&nameType="0">selected</#if>>请选择</option>
													<option value="1" <#if nameType?? &&nameType="1">selected</#if>>品种</option>
													<option value="2" <#if nameType?? &&nameType="2">selected</#if>>手机号码</option>
													<option value="3" <#if nameType?? &&nameType="3">selected</#if>>昵称</option>
													<option value="4" <#if nameType?? &&nameType="4">selected</#if>>公司名</option>
													<option value="5" <#if nameType?? &&nameType="5">selected</#if>>姓名</option>
													<option value="6" <#if nameType?? &&nameType="6">selected</#if>>负责人</option>
												</select>
										</div>：
							</td>
							<td colspan="3">
							<div style="width:360px;float:left;" >
											<input type="text" name="name" id="name"
													value="${name!''}" class="form-control">
													
													<select name="itemName" id="itemName" style="display: none" class="form-control">
													<#if itemList??>
													<#list itemList as item>
														<option value="${item.id?if_exists}" <#if itemId?? &&itemId=item.id	>selected</#if>>${item.name?if_exists}</option>
													</#list>
													</#if>
													</select>
							</div>
							</td>
							<td align="center">地区：</td>
							<td>
							<div style="width:150px;float:left;">
											
												<select name="prov" id="prov" class="form-control" onchange="getCity()">
													<option value="" >请选择</option>
													<#if areasList??>
													<#list areasList as areas>
													<option value="${areas.id?if_exists}" <#if prov?? &&prov=areas.id	>selected</#if>>${areas.name?if_exists}</option>
													</#list>
													</#if>
												</select>
										</div>
							</td>
							<td align="center" width="20px"></td>
							<td>
							<div style="width:150px;float:left;display: none" id="cityDiv">
											
												<select name="city" id="city" class="form-control">
												</select>
										</div>
							</td>
							</tr>
							
							<tr  style="margin:20px;display:block;">
							<td><div style="width:150px;float:left;padding-left:  20px;">
												<select name="timeType" id="timeType" class="form-control">
													<option value="" >请选择</option>
													<option value="0" <#if timeType?? &&timeType='0'>selected</#if>>加入时间</option>
													<option value="1" <#if timeType?? &&timeType='1'>selected</#if>>上次成交时间</option>
												</select>
										</div>：
							</td>
					
						
								<td>
								
									<input type="text" id="startDay" name="startDay" class="form-control" onClick="WdatePicker()"  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 173px" value="${startDay!''}"/>
						
									</td>
								
								<td align="center">至</td>
								<td>
					
								<input type="text" id="endDay" name="endDay" onClick="WdatePicker()" class="form-control"  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"style="width: 173px" value="${endDay!''}"/>
	
								</td>
							
							
							
							<td align="right" colspan="2">
								
								<div class="col-md-2" style="padding-left: 40px">
									<button class="btn green" onclick="refet()" >
														<i class="fa"></i> 重置
										</button>
									</div>	
									<button class="btn green" >
													<i class="fa fa-search"></i> 搜索
									</button>
							</td>
							</table>	
						</div>
						</form>
						
						<div class="portlet light bordered">
							<div class="portlet-body">
								<div class="row">
									<div style="float: left;width: 100px; margin-left: 15px;">
									
										<button class="btn green" onclick="delByIds()">

											批量删除
										</button>
									
									</div>
									
							
								<div style="float: right;width: 28%;text-align: right; padding-right: 18px; float: right;" id="hide_div_2">
									<button class="btn green" onclick="window.location='${request.getContextPath()}/customer/toAddCustomer.do'">
											新建客户
										</button>
									<button class="btn green" onclick="supplyExport();">
									导出
									</button>
								</div>
							</div>
							<div class="table-scrollable">
								<table class="table table-striped table-bordered table-hover ttTbl"
									id="myTable">
									<thead>
										<tr>
											<th class="table-checkbox"><input type="checkbox"
													class="group-checkable" data-set="#myTable .checkboxes" />
												</th>
											<th scope="col">手机</th>
											<th scope="col">废旧品种</th>
											<th scope="col">姓名</th>
											<th scope="col">公司名</th>
											<th scope="col">地区</th>
											<th scope="col">上次成交时间</th>
											<th scope="col">负责人</th>
											<th scope="col">加入时间</th>
											<th scope="col">是否推广</th>
											<th scope="col">操作</th>
										</tr>
									</thead>
									<tbody>
								<#list customerList as customer>
										<tr>
											<td><input type="checkbox" class="checkboxes"
												name="checkboxes" value="${customer.id?if_exists}" /></td>
											<td><a href="javascript:showCustomerDetail(${customer.id?if_exists})">${customer.phone?if_exists}</a></td>
											<td>${customer.itemName?if_exists}</td>
											<td>${customer.name?if_exists}</td>
											<td class="center">${customer.companyName?if_exists}</td>
											<td class="center">
											<#if customer.goodsCityName??>
												<#if customer.goodsProvName==customer.goodsCityName>
												${customer.goodsProvName?if_exists}
												<#else>
												${customer.goodsProvName?if_exists}/${customer.goodsCityName?if_exists}
												</#if>
											<#else>
											${customer.goodsProvName?if_exists}
											</#if>
											</td>
											<td class="center">
											<#if (customer.dealTime)??>${(customer.dealTime)?string("yyyy-MM-dd")}</#if>
											</td>
											<td class="center">${customer.userName?if_exists}</td>
											<td class="center">
											<#if (customer.createdAt)??>${(customer.createdAt)?string("yyyy-MM-dd")}</#if>
											</td>
											
											<td class="center">
											<#if customer.isSpread?? &&customer.isSpread==0>
											未推广
											</#if>
											<#if customer.isSpread?? &&customer.isSpread==1>
											已推广
											</#if>
											</td>
											<td>
												<a href="javascript:showCustomerDetail(${customer.id?if_exists})" class="btn btn-xs green">查看 </a> 
												
												<#if dayType?? &&dayType!="5">
												<a href="javascript:toUpdateCustomer(${customer.id?if_exists})" class="btn btn-xs green">修改 </a> 
					               				<a href="javascript:takeCustomerOrder(${customer.id?if_exists},${saleType?if_exists}
					               				)" class="btn btn-xs green"> 
					               				生成订单 
					               				
					               				</a>
					               				</#if>
					               				
												</td>
										</tr>
										</#list>
									</tbody>
								</table>
							</div>
							<div style="width:80%;margin:0 auto;">
										<div id="kkpager"></div>
										<input type="hidden" value="${totalPage}" id="totalPage">
										<input type="hidden" value="${totalRecords}" id="totalRecords">
										<input type="hidden" value="${city?if_exists}" id="city1">
										<input type="hidden" value="${dayType?if_exists}" id="dayType">
										<input type="hidden" value="${type?if_exists}" id="type">
								</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

</div>


	<!-- END PAGE CONTAINER -->

<!-- 底部开始 -->
<#include "/include/foot.html" />
<!-- 底部结束 -->
	
	<!--[if lt IE 9]>
<script src="${request.getContextPath()}/Public/assets/global/plugins/respond.min.js"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/excanvas.min.js"></script>
<![endif]-->
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery-migrate.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/js/bootstrap.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery.blockui.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery.cokie.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/uniform/jquery.uniform.min.js"
		type="text/javascript"></script>

	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery.sparkline.min.js"
		type="text/javascript"></script>

	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"
		type="text/javascript"></script>

	<script
		src="${request.getContextPath()}/Public/assets/global/scripts/metronic.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/layout.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/indexComponent.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/commonUtils.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/tc.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/ajaxfileupload.js"
		type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/kkpager.min.js" type="text/javascript"></script>
	<script>
		jQuery(document).ready(function() {
			Metronic.init(); // init metronic core componets
			Layout.init(); // init layout
			CommonUtils.checkInit();
		});
		recordDate();
		selectColumn();
		function refet(){
			$("#nameType").val("");
			$("#name").val("");
			$("#prov").val("");
			$("#city").val("");
			$("#timeType").val("");
			$("#startDay").val("");
			$("#endDay").val("");
			$("#saleType").val("1");
		}
		
		//批量删除
		function delByIds(){
			var str=document.getElementsByName("checkboxes");
			var objarray=str.length;
			var chestr="";
			for (i=0;i<objarray;i++)
			{
			  if(str[i].checked == true)
			  {
			   chestr+=str[i].value+",";
			  }
			}
			if(chestr == "")
			{
				CommonUtils.succModal("系统提示", "你没有选中一条记录！");
			}else{
			  $.ajax({  
			        url : "${request.getContextPath()}/customer/deleteCustomer.do?idS="+chestr,   
			        dataType : 'json', 
					success : function(data) {
						 if(data.info=='success'){
							 CommonUtils.succModal2("系统提示", "删除成功！", "${request.getContextPath()}/customer/customerList.do");
							 //CommonUtils.succModal("系统提示", "删除成功");
							
						 }else{
							 CommonUtils.succModal("系统提示", "删除失败");
						 }
			        },  
			        error : function(data)//服务器响应失败处理函数  
			        {  
			         alert("请求失败");
			        }  
			    }); 
			}
		}
		function reload(){
			 location.reload();
		}
		//根据省获取市
		function getCity(){
			var provId = $("#prov").val();
			var city1 = $("#city1").val();
			if(provId!=''){
				if(provId!=1&&provId!=2&&provId!=3&&provId!=4){
					$('#cityDiv').css('display','block');
					$.ajax({  
				        url : "${request.getContextPath()}/customer/showCity.do?provId="+provId,   
				        dataType : 'json', 
						success : function(result) {
							 if(result.info=='success'){
								 var jsonData = eval(result.areasList);
								$("#city").empty();
								$("#city").append("<option value=''>请选择</option>");
								 $.each(jsonData, function(index, areas){
									 if(city1==areas.id){
										 $("#city").append(
													"<option value='"+areas.id+"' selected>" + areas.name + "</option>");
									 }else{
										 $("#city").append(
													"<option value='"+areas.id+"' >" + areas.name + "</option>");
									 }
									
								});  
							 }else{
								 CommonUtils.succModal("系统提示", "获取失败");
							 }
				        },  
				        error : function(data)//服务器响应失败处理函数  
				        {  
				         alert("请求失败");
				        }  
				    }); 
				}else{
					$('#cityDiv').css('display','none');
				}
				
			}
			  
		}
		function recordDate() {
			var nowDate = new Date();
			//$('#date-picker').attr("date-date",nowDate.getFullYear()+"/"+parseInt(nowDate.getMonth()+1)+"/"+nowDate.getDate());
			$('.date-picker').datepicker({
				autoclose : true
			});
		}
		function selectColumn() {
			var value = $("#nameType").val();
			$('#name').show();
			$('#itemName').hide();
			if (value == 1) {
				$('#itemName').show();
				$('#name').hide();
			} 
		}
		function displayss(value, selId) {
			document.getElementById(selId).value = value;
		}
		//初始化分页插件
		function getParameter(name) { 
			var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 
			var r = window.location.search.substr(1).match(reg); 
			if (r!=null) return unescape(r[2]); return null;
		}
		
		//init
		$(function(){
			getCity();
			var totalPage = $('#totalPage').val();
			var totalRecords = $('#totalRecords').val();
			var nameType = $('#nameType').val();
			var name = $('#name').val();
			var prov = $('#prov').val();
			var city = $('#city').val();
			var timeType = $('#timeType').val();
			var startDay = $('#startDay').val();
			var endDay = $('#endDay').val();
			var dayType = $('#dayType').val();
			var itemName = $('#itemName').val();
			var saleType = $('#saleType').val();
			var type = $('#type').val();
			var pageNo = getParameter('pno');
			if(!pageNo){
				pageNo = 1;
			}
			//生成分页
			//有些参数是可选的，比如lang，若不传有默认值
			kkpager.generPageHtml({
				pno : pageNo,
				//总页码
				total : totalPage,
				//总数据条数
				totalRecords : totalRecords,
				
				getLink : function(n){
					return this.hrefFormer + this.hrefLatter + "?pno="+n+"&nameType="+nameType+"&prov="+prov
							+"&city="+city+"&name="+encodeURI(encodeURI(name))+"&saleType="+saleType+"&timeType="
							+timeType+"&startDay="+startDay+"&endDay="+endDay+"&dayType="+dayType+"&itemName="+itemName
							+"&type="+type;
				}	
			});
		});
	function takeCustomerOrder(customerId,saleType){
		if(saleType=='2'){//供应商
			window.location = "${request.getContextPath()}/order/toAddOrderBySupCustomer.do?id="+ customerId;
		}else{
			window.location = "${request.getContextPath()}/order/toAddOrderByPurCustomer.do?id="+ customerId;
		}
		
	}
		function supplyExport() {
			var checks = CommonUtils.getCheckedBoxs().join(",");
			var prov = $("#prov").val();
			var city = $("#city").val();
			var timeType = $("#timeType").val();
			var startDay = $("#startDay").val();
			var endDay = $("#endDay").val();
			var saleType = $("#saleType").val();
			var nameType = $("#nameType").val();
			var name = encodeURIComponent(encodeURIComponent($("#name").val()));
			var urlParam = "?prov=" + prov + "&city=" + city
					+ "&timeType=" + timeType + "&startDay=" + startDay
					+ "&endDay=" + endDay+ "&saleType=" + saleType+ "&name=" + name+"&nameType="+nameType
					+"&ids="+checks;
			
			window.location = "${request.getContextPath()}/customer/poolExportDel.do"
					+ urlParam;
		}
		function showCustomerDetail(id){
			window.location = "${request.getContextPath()}/orders/customerDetail.do?customerId="+id;
		}
		
		function toUpdateCustomer(id){
			window.location = "${request.getContextPath()}/customer/toUpdateCustomer.do?customerId="+id;
		}
	</script>

</body>
</html>